using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace SysFrame.BP
{
    /// <summary>
    /// 基础方法类
    /// </summary>
    public class BPBase
    {
        /// <summary>
        /// 得到实现类
        /// 读取配置文件 Setup SQLTYPE 节点
        /// 1 SQL 2 MySQL
        /// </summary>
        /// <param name="usingstr">实现类的命名空间</param>
        /// <param name="classname">实现类的类名 前缀固定 SQL Server：SQL+classname;MySQL:MySQL+classname</param>
        /// <returns>实现类 要强转成接口</returns>
        public static object GetAchieve(string usingstr,string classname)
        {
            object obj = new object();
            Assembly assembly = Assembly.GetExecutingAssembly(); // 获取当前程序集 
            //读取配置文件
            //IniOP iniop = new IniOP();
            try
            {
                //string sqltype = iniop.ReadValue("Setup", "SQLTYPE");
                string sqltype = DataBase.SQLTYPE;
                if (sqltype == "1")
                {
                    obj = assembly.CreateInstance(usingstr + ".SQL" + classname);
                }
                else if (sqltype == "2")
                {
                    obj = assembly.CreateInstance(usingstr + ".MySQL" + classname);
                }
            }
            catch { }
            return obj;
        }
    }
}
